﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Web;
using Pap.Data;

namespace Pap.Core.Utilities
{
    /// <summary>
    /// 
    /// </summary>
    public static class RegistryInfo
    {
        /// <summary>
        /// Current User ID
        /// </summary>
        /// <value>
        /// The user ID.
        /// </value>
        public static Guid UserID
        {
            get
            {
                return (Guid)HttpContext.Current.Session["UserID"];
            }
            set
            {
                HttpContext.Current.Session["UserID"] = value;
            }
        }

        /// <summary>
        /// Current User CommitteeID
        /// </summary>
        /// <value>
        /// The committee ID.
        /// </value>
        public static Guid CommitteeID
        {
            get
            {

                if (HttpContext.Current != null && HttpContext.Current.Session != null)
                {
                    var committeeId = HttpContext.Current.Session["CommitteeID"];
                    if(committeeId == null)
                    {
                        committeeId = new Guid(ConfigurationManager.AppSettings["CommitteeID"]);
                        HttpContext.Current.Session["CommitteeID"] = committeeId;
                    }
                    return (Guid) committeeId;
                }
                return new Guid(ConfigurationManager.AppSettings["CommitteeID"]);
            }
        }

        /// <summary>
        /// Gets the images.
        /// </summary>
        public static Dictionary<string, IList<IImage>> Images
        {
            get
            {
                var imageDic = HttpContext.Current.Session["Images"] as Dictionary<string, IList<IImage>>;
                if (imageDic == null)
                {
                    imageDic = new Dictionary<string, IList<IImage>>();
                    HttpContext.Current.Session["Images"] = imageDic;
                }
                return imageDic;
            }

        }
    }
}